﻿
function document.oncontextmenu() {
    return;
    var s = event.srcElement.tagName;
    // For Selection Ranges, s will be UNDEFINED
    if (s && s != "INPUT" && s != "TEXTAREA" || event.srcElement.disabled || document.selection.createRange().text.length == 0) {
        event.returnValue = false;
    }
}

function document.onselectstart() {
    var s = event.srcElement.tagName;
    if (s != "INPUT" && s != "TEXTAREA") event.returnValue = false;
}

function document.ondragstart() {
    event.returnValue = false;
}

// 功能：以 open 方式打开全屏窗口
function openMyFullWin(sPath, sName) {

    window.open(sPath);
    return;
    var iX = window.screen.width - 10;
    var iY = window.screen.height - 60;
    if (!sName) sName = "";

    try {
        window.open(sPath, sName, "left=0,top=0,width=" + iX + ",height=" + iY + ",status=1,resizable=1");
    }
    catch (e) { }
}

// 功能：以 open 方式打开窗口
function openMyWin(sPath, sName, iX, iY) {
    openStdWin(sPath, sName, iX, iY);
}

function openStdWin(sPath, sName, iX, iY) {
    if (!iX) iX = 800;
    if (!iY) iY = 552;
    if (!sName) sName = "";

    var iL, iT;
    iL = (window.screen.width - iX) / 2;
    iT = (window.screen.height - iY - 80) / 2;

    if (iL < 0) iL = 0;
    if (iT < 0) iT = 0;

    try {
        window.open(sPath, sName, "left=" + iL + ",top=" + iT + ",width=" + iX + ",height=" + iY + ",status=1,resizable=1");
    }
    catch (e) {
    }
}

// 功能：以 showModalDialog 方式打开窗口
// 参数：sPath		-- 文件路径，必须包含完整的文件路径
//		 sParams	-- 后缀参数，格式如：paramname1=escape(param1)&paramname2=escape(param2)&...
function openMyDlg(sTitle, sPath, sParams, oArgs, iX, iY) {

    if (!iX) iX = 500;
    if (!iY) iY = 340;

    var sURL = "/FrameTemp0.aspx";
    sURL += "?title=" + escape(sTitle);
    sURL += "&height=";
    sURL += "&filename=" + escape(sPath);
    sURL += "&param=" + escape(sParams);

    return window.showModalDialog(sURL, oArgs, "dialogWidth:" + iX + "px;dialogHeight:" + iY + "px; status:0; help:0; resizable:0; center:1;");
}

function openStdDlg(sPath, oArgs, iX, iY) {
    return window.showModalDialog(sPath, oArgs, "dialogWidth:" + iX + "px;dialogHeight:" + iY + "px;help:0;status:0;scroll:0;center:1");
}

function openFrmObj(sUrl, sName, iType) {
    var url = _sRoot + getObjUrl(iType) + sUrl; 	//根据iType从注册信息中找出编辑页面的url
    switch (Number(iType)) {
        case None:
            // don't open anything
            break;
        default:
            openStdWin(url, sName);
    }
}

function openObj(iType, sId) {
    var sUrl = "";
    if (sId) {
        sUrl += "?id=" + sId;
    }
    openFrmObj(sUrl, buildWinName(sId), iType);
}

function openObjEx(iType, iParentType, sParentId, sParams) {
    var url = "";
    if (sParentId) {
        url += "?pId=" + sParentId + "&pType=" + iParentType;
    }
    if (typeof (sParams) != "undefined") {
        url += sParams;
    }
    openFrmObj(url, buildWinName(), iType);
}

function getObjUrl(i) {
    switch (Number(i)) {
        case None:
        case AppLicense: return "";  // does not open a form
    }
    alert(i + " - 没有注册该对象代码！");          //^^
    return "";
}

function openPopup() {
    return window.createPopup();
}

function buildWinName(s) {
    if (s) return s.replace(/[-\{\}]/g, "");
    var d = new Date();
    return d.getTime();
}

function document.onkeydown() {
    if (event.keyCode == 116) {
        // 屏蔽 F5
        event.keyCode = 0;
        event.returnValue = false;
    }
    else if (event.keyCode == 13) {
        if (event.srcElement.tagName == "SELECT")
            event.keyCode = 9;

        else if (event.srcElement.tagName == "INPUT") {
            switch (event.srcElement.type) {
                case "checkbox":
                case "hidden":
                    //case "file":
                case "image":
                case "password":
                case "radio":
                case "text":
                    event.keyCode = 9;
            }
        }
    }
}

//初始化命名空间
var Runda = Runda ? Runda : {};
Runda.Http = Runda.Http ? Runda.Http : {};
//第一种封装方法
Runda.Http.URL = Runda.Http.URL ? Runda.Http.URL : {
    getQueryString: function(ParamName) {
        if (location.href.indexOf("?") == -1 || location.href.indexOf(ParamName + '=') == -1) {
            return '';
        }

        var queryString = location.href.substring(location.href.indexOf("?") + 1);
        var parameters = queryString.split("&");

        var pos, paraName, paraValue;
        for (var i = 0; i < parameters.length; i++) {
            pos = parameters[i].indexOf('=');
            if (pos == -1) { continue; }

            paraName = parameters[i].substring(0, pos);
            paraValue = parameters[i].substring(pos + 1);

            // 如果查询的name等于当前name，就返回当前值，同时，将链接中的+号还原成空格 #去掉
            if (paraName.toLowerCase() == ParamName.toLowerCase()) {
                return unescape(paraValue.replace(/\+/g, " ").replace(/\#/g, ""));
            }
        }
        return '';
    }, //注意用逗号隔开 
    test: function() {

    } //注意不能够有逗号 
} 
